<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>基本设置</title>
	<link rel="stylesheet" href="/js/plugin/layui-v2.3.0/layui/css/layui.css">
	<link rel="stylesheet" href="/css/reset.css">
	<link rel="stylesheet" href="/css/index.css">
	<link rel="stylesheet" href="/css/project_set.css">
	<script src="/js/jquery-2.1.1.min.js"></script>
	<script src="/js/plugin/layui-v2.3.0/layui/layui.js"></script>
	<script src="/js/common.js"></script>
</head>
<script>
$(document).ready(function() {
	
	if($("#userSexId").val()==1){
		$(":radio[name='userSex'][value='1']").attr("checked","checked");  
	}else{
		$(":radio[name='userSex'][value='0']").attr("checked","checked");  
	}
})
</script>
<style>
	body,html{
		height: auto; 
	}
	.my-line .layui-inline{
		vertical-align: top
	}
</style>
<body>
<input type="hidden" id="userSexId" name="userSexId" th:value="${user.userSex}" />
	<div class="nav-section-content-container" style="padding: 0px">
					<header class="nav-header">
						<div class="nav-section-header-title">
							<span>账号密码</span>
						</div>
					</header>
					<div class="kb-form-container">
						<form class="layui-form" id="defaultForm" th:action="@{/system/org/user/updatePassword}" th:method="post" lay-filter="employee-form">
						<fieldset class="fieldset">
							<legend>登录密码</legend>
								<input type="hidden" id="id" name="id" th:value="${user.id}" />
								<div>
									<div class="layui-form-item layui-form-text">
									    <label class="layui-form-label">当前密码</label>
									    <div class="layui-input-block" style="padding-right: 25px">
									        <input type="password" name="oldPassword" id="oldPassword" onblur="yanzheng()" lay-verify="oldPassword" class="layui-input"  >
									    </div>
									</div>
									<div class="layui-form-item layui-form-text">
									    <label class="layui-form-label">新密码</label>
									    <div class="layui-input-block" style="padding-right: 25px">
									        <input type="password" name="newPassword" id="newPassword" lay-verify="newPassword" class="layui-input" >
									    </div>
									</div>
									<div class="layui-form-item layui-form-text">
									    <label class="layui-form-label">确认密码</label>
									    <div class="layui-input-block" style="padding-right: 25px">
									        <input type="password" name="newPassword1" id="newPassword1" lay-verify="newPassword1" class="layui-input" >
									    </div>
									</div>
								</div>
							</fieldset>
						<fieldset class="fieldset">
							<div class="layui-form-item">
								<button class="layui-btn layui-btn-normal btn-bg" lay-submit lay-filter="formEmployee" id="submit-btn">保存</button>
							</div>
						</fieldset>
						</form>
					</div>
				</div>
</body>
<script>
$(function(){
	setHeight();
    layui.config({
        base: '/js/plugin/layui-v2.3.0/layui/' //此处路径请自行处理, 可以使用绝对路径
    }).extend({
        formSelects: 'formSelects-v3'
    }).use(['element',"layer","form",'formSelects','upload'], function(){
		var layer=layui.layer,form = layui.form,formSelects = layui.formSelects,upload = layui.upload;
		//上传
		layui.use('upload', function(){
			var $ = layui.jquery
			,upload = layui.upload;
		});
		
		form.verify({
			oldPassword: function(value, item){ //value：表单的值、item：表单的DOM对象
	      	  if(value==""){
		       	  return '当前密码不能为空';
		      }
		  }
			,newPassword: function(value, item){ //value：表单的值、item：表单的DOM对象
	      	  if(value==""){
		       	  return '新密码不能为空';
		      }
		  }
			,newPassword1: function(value, item){ //value：表单的值、item：表单的DOM对象
				var pwd=$("#newPassword").val();
				  if(value==""){
				  	  return '确认密码不能为空';
				  }else if(pwd!=value){
					  return '两次密码不一致';
				  }
		  }
		  
		  
		}); 
		//监听提交
		  form.on('submit(formEmployee)', function(data){
			  $.post($("#defaultForm").attr('action'), data.field, function(result) {
					layer.msg(result.msg);
				}, 'json');
				return false;
		  });
		
	});
})
function yanzheng(){
	var oldPassword=$("#oldPassword").val();
	$.post("/system/org/user/checkPassword", {oldPassword:oldPassword}, function(result) {
  		if(!result.valid){
  			layer.msg("当前密码不正确！");
  			$("#oldPassword").val("");
		}
	}, 'json');
}
function setHeight(){
    var h = document.body.clientHeight;
    window.parent.setiframeWrap(h);
}
</script>
</html>